<?php

namespace app\admin\model\shopro\user\wallet;

use think\Model;


class Log extends Model
{

    

    

    // 表名
    protected $name = 'shopro_user_wallet_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'wallet_type_text',
        'wm_types_text',
        'oper_type_text',
        'is_refund_text'
    ];
    

    
    public function getWalletTypeList()
    {
        return ['money' => __('Wallet_type money'), 'score' => __('Wallet_type score')];
    }

    public function getWmTypesList()
    {
        return ['xt' => __('Wm_types xt'), 'pt' => __('Wm_types pt'), 'sj' => __('Wm_types sj'), 'yst' => __('Wm_types yst')];
    }

    public function getOperTypeList()
    {
        return ['user' => __('Oper_type user'), 'store' => __('Oper_type store'), 'admin' => __('Oper_type admin'), 'system' => __('Oper_type system')];
    }

    public function getIsRefundList()
    {
        return ['1' => __('Is_refund 1'), '0' => __('Is_refund 0')];
    }


    public function getWalletTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['wallet_type']) ? $data['wallet_type'] : '');
        $list = $this->getWalletTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getWmTypesTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['wm_types']) ? $data['wm_types'] : '');
        $list = $this->getWmTypesList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getOperTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['oper_type']) ? $data['oper_type'] : '');
        $list = $this->getOperTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsRefundTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_refund']) ? $data['is_refund'] : '');
        $list = $this->getIsRefundList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function store()
    {
        return $this->belongsTo('app\admin\model\shopro\Store', 'store_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
